     // loding加载弹出
		function run_waitMe(enterprise_effect){
			$('#register_enterprise').waitMe({
				effect: 'ios',
				bg: 'rgba(16,128,242,0)',
				text: '提交中...',
				color:'#fff',
				padding:'10px',
				sizeW:'',
				sizeH:'',
				source: 'img.svg'
			});
		}

		
	
$(function (){
	
	
	$('._identity_cards_pic').click(function(){
		rm_auth_error('identity_cards_pic');
	});
	$('._business_licence_pic').click(function(){
		rm_auth_error('business_licence_pic');
	});	
	
  //企业认证提交
  $('._enterprise_auth_submit').click(function (){
    var enterprise_name = $('._enterprise_name').val();
    var web_site = $('._web_site').val();
    var contacts = $('._contacts').val();
    var business_licence_no = $('._business_licence_no').val();
    // var business_licence_pic = $('._business_licence_pic').val();
    var business_licence_pic = $('._business_licence_pic').attr('data-src');

    var contacts_mobile = $('._contacts_mobile').val();

    //信息判断
    if(stringIsNull(enterprise_name)){
    	add_auth_error("enterprise_name","请输入公司名称");
    }
    
    //信息判断
    if(stringIsNull(contacts)){
    	add_auth_error("contacts","请输入联系人姓名");
    }
  
    //信息判断
    if(stringIsNull(business_licence_no) == true){
    	add_auth_error("business_licence_no","请输入营业执照编号");
    }
    
    if(stringIsNull(business_licence_pic)){
    	add_auth_error("business_licence_pic","请上传营业执照照片");
    }
    
    //信息判断
    if(stringIsNull(contacts_mobile) == true){
    	add_auth_error("contacts_mobile","请输入电话号码");
    }
 
    if(stringIsNull(enterprise_name) || stringIsNull(contacts) || stringIsNull(business_licence_no) || stringIsNull(contacts_mobile) || stringIsNull(business_licence_pic)){
    	return;
    }
    
    if(!checkMobile(contacts_mobile) == true){
    	add_auth_error("contacts_mobile","请输入正确的电话号码");
    	//return;
    }
    
//	if (haserror('_blur_rz')) {
//		return;
//	}
    
    //ajax提交
    var data = {};
    data.enterprise_name= enterprise_name;
    data.web_site= web_site;
    data.contacts= contacts;
    data.business_licence_no= business_licence_no;
    data.business_licence_pic= business_licence_pic;
    data.contacts_mobile= contacts_mobile;
    data.auth_type = 2;//企业认证

    //若原来认证是个人认证，则不可能去更新企业认证信息
    var new_select_auth_type = $('._old_auth_type').val();
    if( new_select_auth_type==$('._user_type').val() ){//为2时，才表明原先也是企业认证
      data.auth_id = $('._auth_id').val();//原认证编号id
    }
    
    
	var cur = $(this);
	// 按钮置为不可点击
	it_enable(cur, true);
	$('#register_enterprise').text('');
	run_waitMe('enterprise_effect');
	
    $.ajax({
      url:'/apiworks/auth.html',
      type:'POST',
      dataType:'json',
      async:true,
      data:data,
      success:function (req){
    	  it_enable(cur, false);
		  $('#register_enterprise').waitMe('hide');
		  $('#register_enterprise').text('提交认证');
        if(req.status==200){
        	show_msg({msg:'信息已提交',type:'ok',time:2000});
        	if(req.data==2){
        		location.href="/apiworks/userinfo.html";
        	}else{
        		location.href="/user/index.html";
        	}
        }else{
        	if(req.status==1005){
        		show_msg({msg:req.msg,type:'ok',time:2000});
        	}else{
        		add_auth_error(req.data,req.msg);
        	}
          return;
        }
        
      },
      error:function (){
    	it_enable(cur, false);
		$('#register_enterprise').waitMe('hide');
		$('#register_enterprise').text('提交认证');
        show_msg({msg:'系统异常',type:'error',time:2000});
      }
    });

  });
  
  //个人认证提交
  $('._user_auth_submit').click(function (){
    var user_name = $('._user_name').val();
    var identity_cards_no = $('._identity_cards_no').val();
    // var identity_cards_pic = $('._identity_cards_pic').val();
    var identity_cards_pic = $('._identity_cards_pic').attr('data-src');

    var user_mobile = $('._user_mobile').val();

    //信息判断
    if(stringIsNull(user_name) == true){
    	add_auth_error("user_name","请输入姓名");
    	//return;
    }
    
    if(stringIsNull(identity_cards_pic) == true){
    	add_auth_error("identity_cards_pic","请上传身份证照片");
    }
    
    if(stringIsNull(identity_cards_no) == true){
  	   add_auth_error("identity_cards_no","请输入身份证号码");
	   //return;
    }
    
    if(stringIsNull(user_mobile) == true){
       add_auth_error("user_mobile","请输入手机号码");
       //return;
    }
    
    if(stringIsNull(user_name) || stringIsNull(identity_cards_no) || stringIsNull(user_mobile) || stringIsNull(identity_cards_pic)){
    	return;
    }
    
    if(!checkMobile(user_mobile)){
       add_auth_error("user_mobile","请输入正确的手机号码");
       return;
    }

//	if (haserror('_blur_rz')) {
//		return;
//	}
    
    //ajax提交
    var data = {};
    data.user_name= user_name;
    data.identity_cards_no= identity_cards_no;
    data.identity_cards_pic= identity_cards_pic;
    data.user_mobile= user_mobile;
    data.auth_type = 1;//个人认证


		function run_waitMe(user_effect){
			$('#register_user').waitMe({
				effect: 'ios',
				bg: 'rgba(16,128,242,0)',
				text: '提交中...',
				color:'#fff',
				padding:'10px',
				sizeW:'',
				sizeH:'',
				source: 'img.svg'
			});
		}
		
	var cur = $(this);
	// 按钮置为不可点击
	it_enable(cur, true);
	$('#register_user').text('');
	run_waitMe('user_effect');
	
	
    $.ajax({
      url:'/apiworks/auth.html',
      type:'POST',
      dataType:'json',
      async:true,
      data:data,
      success:function (req){
    	  
    	it_enable(cur, false);
		  $('#register_user').waitMe('hide');
		  $('#register_user').text('提交认证');
    	
        if(req.status==200){
        	show_msg({msg:'信息已提交',type:'ok',time:2000});
        	if(req.data==2){
        		location.href="/apiworks/userinfo.html";
        	}else{
        		location.href="/user/index.html";
        	}
        }else{
        	if(req.status==1005){
        		show_msg({msg:req.msg,type:'ok',time:2000});
        	}else{
        		add_auth_error(req.data,req.msg);
        	}
          return;
        }
      },
      error:function (){
    	it_enable(cur, false);
		  $('#register_user').waitMe('hide');
		  $('#register_user').text('提交认证');
        show_msg({msg:'系统异常',type:'error',time:2000});
      }
    });

  });

  //上传图片初始化
  var uploader = WebUploader.create({
      // 选完文件后，是否自动上传。
      auto: true,

      // swf文件路径
      swf: '/Public/images/Uploader.swf',
      // 文件接收服务端。
      server: '/common/uploadfiy.html',
      // 选择文件的按钮。可选。 内部根据当前运行是创建，可能是input元素，也可能是flash.
      //pick: '#viewfile',
      duplicate : true,//允许重复上传相同图片
      pick:{
        id: '._business_licence_pic,._identity_cards_pic', 
        label: '上传照片' 
      },
      // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
      resize: false,

      // 只允许选择图片文件。
      accept: {
          title: 'Images',
          extensions: 'jpg,png,jpeg',
          mimeTypes: 'image/*'
      },
      fileSingleSizeLimit: 0.5 * 1024 * 1024 // 0.5 M
  });

  uploader.on( 'uploadSuccess', function( file ,data) {
      if($('._user_type').val()==2){
        var that = $('._business_licence_pic');
      }else{
        var that = $('._identity_cards_pic');
      }
      //show_msg({type:'ok',title:data.data});
      //改变div背景图片
      that.css("background","url("+data.data+")");
      that.attr('data-src',data.data);
      //$( '#'+file.id ).find('p.state').text('已上传');
  });
  uploader.on('error',function (string){
      var error_div_box,error_msg_box;

      if($('._user_type').val()==2){
        error_div_box = '#business_licence_pic_id';
        error_msg_box = '#business_licence_pic_msg';
      }else{
        error_div_box = '#identity_cards_pic_id';
        error_msg_box = '#identity_cards_pic_msg';
      }
      $(error_div_box).show();
      if(string =='Q_TYPE_DENIED'){
        $(error_msg_box).html('图片仅支持jpg、png两种格式');
      }else if(string == 'F_EXCEED_SIZE'){
        
        $(error_msg_box).html('图片过大,请上传不超过500k的图片');
      }else{
        $(error_msg_box).html('请上传正确的图片');
      }

    });
  
  
});

function setTab(tab_name,obj,typevalues){
  $('._tab_box').removeClass('hr');
  $(obj).addClass('hr');

  $("._tab_colum").hide();
  $("#"+tab_name).show();

  $('._user_type').val(typevalues);

  //user_type = typevalues;
}
